import React, { Component } from "react";

import { connect } from "react-redux";
import { incrementAction } from "./store/actionCreator";

const mapStateToProps = (state) => {
  return {
    count: state.count,
  };
};

const mapDispatchToProps = (dispatch) => {
  return {
    increment() {
      dispatch(incrementAction());
    },
  };
};

@connect(mapStateToProps, mapDispatchToProps)
class Count extends Component {
  state = {};
  render() {
    return (
      <>
        <span>{this.props.count}</span>
        <button onClick={this.props.increment}>+</button>
      </>
    );
  }
}

export default Count;
